import { createApp } from 'vue'
import './style.css'
import App from './App.vue'

//使用状态管理
import Pinia from '/src/store/index.js'

//使用路由
import router from "/src/router/index.js"

//ant-design-vue
import 'ant-design-vue/dist/reset.css';
import Antd from 'ant-design-vue';


//arcgis for javascript样式
import '@arcgis/core/assets/esri/themes/light/main.css'


//响应式
import '/src/utils/rem.js'

//照片预览
import 'viewerjs/dist/viewer.css'

//图片垃懒加载
import lazyload from 'vue-lazy-load'
import VueViewer from 'v-viewer'

//加密
import aes from "./utils/aes.js"

router.beforeEach((to, from, next) => {
    let encode = to.fullPath.split("?")[1]
    let decode = aes.decryptedFn(encode)
    decode.split("&").forEach(item => {
        let arr = item.split("=")
        window[arr[0]] = arr[1]
    })

    next()
})


window.GetQueryString = function GetQueryString(name){
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r){
        return r[2]
    }else{
        return ''
    }
}

let app = createApp(App)
app.directive('gradientTitle',(el, binding, vnode) => {
    el.style.fontFamily = 'YouSheBiaoTiHei';
    el.style.fontWeight = 'bold';
    el.style.fontStyle = 'italic';
    el.style.color = 'rgba(5, 28, 55, 0.42)';
    el.style.background = 'linear-gradient(180deg,rgba(14, 197, 236, 0.36) 5%, rgba(49, 190, 255, 0.36) 10%, #fff 60%)';
    el.style['-webkit-background-clip'] = 'text';
    el.style['-webkit-text-fill-color'] = 'transparent';
})


app.use(lazyload,{
        loading: '默认图片',
        error: '加载错误图片'
    }
)
app.use(VueViewer)
app.use(Antd);
app.use(Pinia)
app.use(router)
app.mount('#app')
